<?php


use Phinx\Migration\AbstractMigration;

class Admin extends AbstractMigration
{
    public function change()
    {
        $table = $this->table('admin');

        $table->addColumn('username', 'string', ['limit'=>30, 'default'=>'']);
        $table->addColumn('password', 'string', ['limit'=>255, 'default'=>'']);
        $table->addColumn('create_time', 'timestamp', ['default'=>'CURRENT_TIMESTAMP']);
        $table->addColumn('login_time', 'timestamp', ['update'=>'CURRENT_TIMESTAMP']);
        $table->addColumn('disabled', 'boolean', ['default'=>0]);
        $table->addIndex(['username'], ['unique'=>true, 'name'=>'adx_username']);

        $table->insert([
            'username'=>'admin',
            'password'=>password_hash('123456', PASSWORD_DEFAULT)
        ]);

        $table->save();
    }
}
